<template>
  <div class="table-container">
    <el-table :data="tableData" border style="width: 100%" :span-method="arraySpanMethod">
      <el-table-column prop="deptName" label="单位" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="basis" label="判定依据" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="num" label="总量" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="accordNum" label="符合" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="unAccordNum" label="不符合" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="unInvolvedNum" label="不适用" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="inspectionTime" label="最近排查时间" min-width="80"  align="center"></el-table-column>
      <el-table-column prop="createBy" label="排查人员" min-width="80"  align="center"></el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "majorHazardTable",
  props: {
    tableData: {
      type: Array,
      default: () => [],
    },
  },
  methods:{
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      // 根据 row.extra1 相同的行进行合并 前5列和操作列
      if (columnIndex === 0 ) {
        if (
          rowIndex > 0 &&
          row.deptName === this.tableData[rowIndex - 1].deptName
        ) {
          return [0, 0];
        }
        const count = this.tableData.filter(
          (item) => item.deptName === row.deptName
        ).length;
        return [count, 1];
      }
      // 其他情况不合并
      return [1, 1];
    },
  }
};
</script>

<style lang="scss" scoped></style>
